//----------百度统计代码----------
var _hmt = _hmt || [];
(function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?ca649477ab8c294fcd072a7f3a74b5c2";
    var s = document.getElementsByTagName("script")[0]; 
    s.parentNode.insertBefore(hm, s);
})();

var api = allAPI || {}
    ,all = globalModule || {}
    ,theRoot = all.root() || ''
    ,wapRoot = all.wapRoot() || ''
;


var oHost = window.location.hostname  //定义变量为网站域名
	,wLanip = 'http://'+oHost  //定义变量为根目录网址
	,theUserAgent = navigator.userAgent
	,loginUserExit = $('a.theUserExit, #dropOut')  //退出按钮
	,loginUserType ,loginUserTypeEN  //登录类型
	,companyPlate ,companyPlate2 ,companyPlateZhi
	,allPlate ,allPlate2 ,allPlateZhi
	,theHome ,theHomeType
	,allModule
    ,popLayerCloseBtn = $('.popLayer').find('.close').find('label[for="popLayer"]')
    // ,headerResAddBtn = $('.header.m').find('.resAdd').find('a')

    ,host = window.location.host
    ,hostname = window.location.hostname
    ,fpath = $('meta.fpath').data('fpath') || ''
    ,frontPath = host + fpath
	,urlPathname = location.pathname
    ,urlSearch = location.search
    ,loading = $('.pageLoading')
	,theResAddIdArticle = ''
	,theResAddIdWechat = ''
	,theResAddIdFriend = ''
	,theResAddIdWeibo = ''
	,theResAddIdStar = ''
	,theResAddIdLive = ''
	,theResAddIdVideo = ''
	,theResAddIdXhs = ''
	,theResAddIdClient = ''
;


//========================================================
all.isLogin();                          //判断用户是否登录
$('#popLayer').prop('checked',false);
getThePlate();                          //获取平台名称和值
all.boswers();                          //判断浏览器版本
all.showNotice();                       //显示公告
// all.popSs();                            //显示弹层图片
all.menuActive();                       //导航条激活
all.exit(loginUserExit);                //退出点击事件
all.closePopLayer(popLayerCloseBtn);    //弹出层关闭按钮点击事件
// all.resAddClick(headerResAddBtn);       //媒介主添加资源

// all.showPopNotice();                    //显示弹框公告
// headerResAddBtn.on('click',all.resAddClick);    //媒介主添加资源
//========================================================


//获取平台名称和值
function getThePlate(){
	// y-z-m.c-r
	var oPathname = window.location.pathname.substr(1)
		,oSearch = window.location.search
		,oPlateZhi = getUrlRequest('plate')
	;
	theHomeType = 'all';

    // 如果是模拟登录，清空localStorage
	// if(oSearch.indexOf('now=')>-1){window.localStorage.clear()}
    // if(/now=/ig.test(location.search)){localStorage.clear()}


	if(!oPathname || oPathname == 'index.html'){  //如果是网站首页
		iam = 'index';
		if(!oPlateZhi){allPlate = 'index'}
		else if(oPlateZhi == 51){allPlate = 'article'}
		else if(oPlateZhi == 13){allPlate = 'wechat'}
		else if(oPlateZhi == 17){allPlate = 'friend'}
		else if(oPlateZhi == 11){allPlate = 'weibo'}
		else if(oPlateZhi == 98){allPlate = 'video'}
	}
	//如果是 软文 微信公众号 朋友圈 新浪微博 直播
	if(oPathname.indexOf('article')>-1){allPlate = companyPlate = 'article'; allPlateZhi = companyPlateZhi = 51}
	if(oPathname.indexOf('wechat')>-1){allPlate = companyPlate = 'wechat'; allPlateZhi = companyPlateZhi = 13}
	if(oPathname.indexOf('friend')>-1){allPlate = companyPlate = 'friend'; allPlateZhi = companyPlateZhi = 17}
	if(oPathname.indexOf('weibo')>-1){allPlate = companyPlate = 'weibo'; allPlateZhi = companyPlateZhi = 11}
	if(oPathname.indexOf('live')>-1){allPlate = companyPlate = 'live'; allPlateZhi = companyPlateZhi = 98}
	//如果是 预约
	if(oPathname.indexOf('star')>-1){
		if(oPlateZhi == 13){allPlate = companyPlate = 'wechat'}
		else if(oPlateZhi == 17){allPlate = companyPlate = 'friend'}
		else if(oPlateZhi == 11){allPlate = companyPlate = 'weibo'}
		allPlate2 = companyPlate2 = 'star';
		allPlateZhi = companyPlateZhi = 30;
	}
	//如果是 纸媒 充值 套餐 报价单
	if(oPathname.indexOf('paper')>-1){allPlate = companyPlate = 'article'; allPlate2 = companyPlate2 = 'paper'; allPlateZhi = companyPlateZhi = 20}
	if(oPathname.indexOf('recharge')>-1){allPlate = companyPlate = 'recharge'}
	if(oPathname.indexOf('Deals')>-1){allPlate = companyPlate = 'article'; allPlate2 = companyPlate2 = 'Deals'}
	if(oPathname.indexOf('resQuote')>-1){
		if(oPlateZhi == 51){companyPlate = 'article'}
		else if(oPlateZhi == 13){companyPlate = 'wechat'}
		else if(oPlateZhi == 17){companyPlate = 'friend'}
		else if(oPlateZhi == 11){companyPlate = 'weibo'}
	}
	//如果是 广告主 媒介主
	if(oPathname.indexOf('companyHome')>-1){theHomeType = 'company'; loginUserType = 2; loginUserTypeEN = 'adv'; theHome = 'companyHome'; iam = 'adv'}
	if(oPathname.indexOf('websiteHome')>-1){theHomeType = 'website'; loginUserType = 1; loginUserTypeEN = 'media'; theHome = 'websiteHome'; iam = 'media'}
}

//获取屏幕分辨率
// function redirectPage() { 
// 	var wjbxue=screen.width;
// 	var hjbxue=screen.height;
// 	return wjbxue+"*"+ hjbxue;
// } 

//根据分辨率来改变网页缩放
// function changeWebPgZoom() {
	
// 	if(redirectPage() == '1366*768') {
// 		$("html").css('zoom','.80');
// 	}else if(redirectPage() == '1360*768') {
// 		$("html").css('zoom','.80');
// 	}else if(redirectPage() == '1280*800') {
// 		$("html").css('zoom','.80');
// 	}else if(redirectPage() == '1280*768') {
// 		$("html").css('zoom','.75');
// 	}else if(redirectPage() == '1280*720') {
// 		$("html").css('zoom','.66');
// 	}else if(redirectPage() == '1280*600') {
// 		$("html").css('zoom','.66');
// 	}else if(redirectPage() == '1152*864') {
// 		$("html").css('zoom','.80');
// 	}else if(redirectPage() == '1024*768') {
// 		$("html").css('zoom','.75');
// 	}else if(redirectPage() == '800*600') {
// 		$("html").css('zoom','.67');
// 	}
// }
// changeWebPgZoom();





// ;(function($){
//     // 避免表单自动填充
//     $(document).find('input.blur').attr('autocomplete','off');
// })(jQuery);


//---------------------
// 判断是PC端or手机端
//---------------------
// ;(function(){
//     var change = 'orientationchange' in window ? 'orientationchange' : 'resize';
//     function judge() {
//         var deviceWidth = document.documentElement.clientWidth
//         	,href = location.href
//         	,pn = location.pathname
//         	,regs = /(\/index\.html|\/companyHome|\/websiteHome|\/user[Login|Reg|Find])/ig
//         ;
//         if(regs.test(href)){
// 	        if(deviceWidth > 768){
// 	            if(/\/wap/ig.test(href)){location.href = href.replace(/\/wap/ig,'')}
// 	        }else{
// 	            if(!/\/wap/ig.test(href)){location.href = href.replace(regs, '\/wap$1').replace(/(\/$)/ig,'$1wap\/index.html')}
// 	        }
//         }
//     };
//     window.addEventListener(change, judge, false);
//     judge();
// })();




//==========================
//--------------------------
//   Website Head Res Add
//  媒介主HEAD部分添加资源
//--------------------------
//==========================
const _WHRA_ = (function(){
	return {
		GORESBTN : $('.GORESADDPG')
		,AUTHBTN : $('.AUTHBUTTON')
		,init : function(){
			if(!/websiteHome/.test(location.pathname)) return;
			// 跳转页面按钮点击事件
			this.GORESBTN.on('click',this.GORESBTNCLICK);
			// 授权按钮点击事件
			this.AUTHBTN.on('click',this.AUTHBTNCLICK);
		}
		// 跳转页面按钮点击事件
		,GORESBTNCLICK : function(){
			var _ = _WHRA_;
			var btn = $(this), href = btn.data('href'), platen = btn.data('platen');
			_.platen = platen;
			// 如果没有href 弹出授权层 并返回
			if(!href){_.popAuth(); return}
			// 页面跳转href
			location.href = href;
		}
		// 弹出授权层
		,popAuth : function(){
			var pop = $('.popLayer2'), auth = pop.find('.box.auth');
			pop.fadeIn(200);
			auth.fadeIn(200).find('.con').hide();
			auth.find('.con.'+this.platen).show();
		}
		// 授权按钮点击事件
		,AUTHBTNCLICK : function(){
			var form = $(this).find('form');
			form.attr('action','/open/login.html');
			form.submit();
		}
	}
}());
_WHRA_.init();




